const TransformPages = require('uni-read-pages')

const {
	webpack
} = new TransformPages()

const path = require("path");
function resolve(dir) {
	return path.join(__dirname, dir);
}

module.exports = {
	transpileDependencies: ['uview-ui'],
	productionSourceMap: false, // 生产打包时不输出map文件，增加打包速度
	configureWebpack: {
		plugins: [
			new webpack.DefinePlugin({
				ROUTES: webpack.DefinePlugin.runtimeValue(() => {
					const tfPages = new TransformPages({
						includes: ['path', 'name', 'meta', 'aliasPath']
					});
					return JSON.stringify(tfPages.routes)
				}, true)
			})
		],
		resolve: {
			alias: {
				"@": resolve("src"),
				"common": resolve("src/common"),
				"components": resolve("src/components"),
				"network": resolve("src/network"),
				"pages": resolve("src/pages"),
				"router": resolve("src/router"),
				"static": resolve("src/static"),
				"store": resolve("src/store")
			}
		}
	}
}
